package com.maolong.fenkufenbiaotest.controller;

import com.maolong.fenkufenbiaotest.pojo.User;
import com.maolong.fenkufenbiaotest.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/list")
    public List<User>  list(){
        return userService.selectAll();
    }

    @PostMapping("/add")
    public void add(User user){
        log.info("add user:{}",user);
        User user1 = new User();
        user1.setName("ahahhahahahha");
        user1.setTime(new Date());
        userService.addUser(user1);
    }
}
